import request from '@/utils/request'

// 按条件分页查询资源接口
export const getResourcePages = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/getResourcePages',
    data
  })
}

// 资源分类请求
export const getResourceCategory = () => {
  return request({
    method: 'GET',
    url: '/boss/resource/category/getAll'
  })
}

// 保存或者更新资源
export const getCreatedOrEdit = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/saveOrUpdate',
    data
  })
}

// 获取编辑页面单个资源
export const getEditResource = id => {
  return request({
    method: 'GET',
    url: `/boss/resource/${id}`
  })
}

// 获取所有资源
export const getAllResource = () => {
  return request({
    method: 'GET',
    url: '/boss/resource/getAll'
  })
}

// 获取角色拥有的资源列表
export const getRoleResources = roleId => {
  return request({
    method: 'GET',
    url: '/boss/resource/getRoleResources',
    params: {
      roleId
    }
  })
}

// 删除资源
export const getDeleteResource = id => {
  return request({
    method: 'DELETE',
    url: `/boss/resource/${id}`
  })
}

// 保存或更新资源分类
export const getSaveOrderUpdate = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/category/saveOrderUpdate',
    data
  })
}

// 删除资源分类，如果资源分类下有资源，不允许删除
export const deleteResource = id => {
  return request({
    method: 'DELETE',
    url: `/boss/resource/category/${id}`
  })
}
